package org.mc.sbd.mqredis.controller;


import org.mc.sbd.mqredis.event.MqEvent;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("redis-mq")
public class SendEventController {
    private final RedisTemplate<String, MqEvent> eventRedisClient;

    public SendEventController(RedisTemplate<String, MqEvent> eventRedisClient) {
        this.eventRedisClient = eventRedisClient;
    }

    @PostMapping("send/{eventFlag}")
    public void send(@PathVariable String eventFlag) {
        eventRedisClient.convertAndSend(eventFlag, new MqEvent("测试事件"));
    }
}
